//
//  BasicMessengeViewController.m
//  DeepBreathing
//
//  Created by rimi on 15/12/28.
//  Copyright © 2015年 rimi. All rights reserved.
//

#import "BasicMessengeViewController.h"
#import "HeaderView.h"
#import "ControllerManager.h"
#import "UserModel.h"
#import "ChooseButtonView.h"

@interface BasicMessengeViewController ()<UIScrollViewDelegate>

@property(nonatomic,strong)UIScrollView *scorView;

@end

@implementation BasicMessengeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    HeaderView *HDV= [[HeaderView alloc]initWithTitleString:@"基本信息" leftImage:@"个人中心按钮_橙色" rightImage:nil color:[UIColor whiteColor]];
    
    HDV.LeftDWblock = ^(){
        [self.navigationController popViewControllerAnimated:YES];
        
            };
    
    
    
    [self.view addSubview:self.scorView];
    [self.view addSubview:HDV];
    
    self.view.backgroundColor = [UIColor colorWithRed:0.902 green:0.902 blue:0.902 alpha:1.0];
    NSArray *array = @[@"手机号",@"姓名",@"年龄",@"性别",@"体重",@"身高",@"哮喘病史",@"是否吸烟",@"有无哮喘       家族史",@"FEV❶",@"PEF"];
    
    for (int i = 0 ; i < 11 ; i ++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(15, 105  + 50 *i, 86, 50)];
        label.numberOfLines = 2;
     
        label.textAlignment = NSTextAlignmentLeft;
        label.text = array[i];
        label.textColor = [UIColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:1.0];
        
        [self.scorView addSubview:label];
    }
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(120, 120, 120, 20)];
    label.text = [UserModel defaultUser].phoneNumber;
    label.textColor =[UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0];
    label.textAlignment = NSTextAlignmentLeft;
    [_scorView addSubview:label];
    
    for (int i = 0; i < 7;i++) {
        
        
        UITextField *textField = [[UITextField alloc]init];
        
        if (i >= 0 && i < 2) {
            textField.frame = CGRectMake(120, 160  + 50 * i, 210, 40);
        }else if (i > 1 && i < 5){
            
            textField.frame = CGRectMake(120, 210 + 50 * i, 210, 40);
        }else if (i >  4 && i < 7){
            
            textField.frame = CGRectMake(120, 310 + 50 * i, 210, 40);
        }
        
                                  
        
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [textField.layer setBorderWidth:2];
        textField.backgroundColor = [UIColor whiteColor];
        [textField.layer setBorderColor:[UIColor orangeColor].CGColor];
        textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 40)];
        textField.leftViewMode = UITextFieldViewModeAlways;
        [self.scorView addSubview:textField];

    }
    
    
    for (int i = 0; i < 3; i ++) {
        for (int j = 0 ; j < 2; j ++) {
                       if (i == 0) {
                           ChooseButtonView *button = [[ChooseButtonView alloc]initWithLeftTitle:@"男" rightTitle:@"女" andFrame:CGRectMake(130, 270, 130, 20)];
                           [self.scorView addSubview:button];
                
            }else if (i > 0){
                ChooseButtonView *button = [[ChooseButtonView alloc]initWithLeftTitle:@"是" rightTitle:@"否" andFrame:CGRectMake(130, 470 + (i - 1)* 45, 130, 20)];
            [self.scorView addSubview:button];
            
            }
                 }
        
        
    }
    
    
    
  

    
    UIButton *sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
    sureButton.frame = CGRectMake(CGRectGetMidX(self.view.frame) - 100, 667 + 50, 150, 150);
    [sureButton setImage:[UIImage imageNamed:@"确认更换按钮"] forState:UIControlStateNormal];
    [sureButton setImage:[UIImage imageNamed:@"确认更换按钮2"] forState:UIControlStateSelected];
    [sureButton addTarget:self action:@selector(saveButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.scorView addSubview:sureButton];
    
 
}


#pragma mark -- getter
-(UIScrollView *)scorView{
    
    if (!_scorView) {
        _scorView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
        _scorView.backgroundColor =[UIColor colorWithRed:0.902 green:0.902 blue:0.902 alpha:1.0];
//        _scorView.pagingEnabled = YES;
        _scorView.showsHorizontalScrollIndicator = NO;
   
        _scorView.contentSize = CGSizeMake(0, 900);
        _scorView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    }
    return _scorView;
    
    
    
    
    
}
-(void)toChoose:(UIButton *)sender{
    
    sender.selected = !sender.selected;
    
    
}
-(void)saveButton:(UIButton *)sender{
    sender.selected = !sender.selected;
    [self otherpopuppromptBox:@"修改失败"];
    
    
    
    
}
-(void)otherpopuppromptBox:(NSString *)string{
    
    UIAlertController  *alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:string preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    
    [alert addAction:action];
    [self presentViewController:alert animated:YES completion:nil];
    
    
}

@end
